#import "AppController.h"
#import "HelloWorldListener.h"
#import "collaboration_subsystem.h"

@implementation AppController

-(id)init
{
	if (self = [super initWithWindowNibName: @"MainMenu"])
	{
		[super init];
	
		d_obj = new ListeningObject();
		collaboration::EVENT_HANDLER->register_object(d_obj);
	}
	
	return self;
}

-(void)awakeFromNib
{
	d_obj->addEventListener(new HelloWorldListener(salida));
}

-(IBAction)imprimir: (id)sender
{
	////////////////////////////////////////
	///////// EMITIR UN EVENTO  ///////////
	///////////////////////////////////////
	
	PairEvent* ev = new PairEvent();
	ev->set_x([x intValue]);
	ev->set_y([y intValue]);
	
	collaboration::EVENT_HANDLER->push(ev);
	
	///////////////////////////////////////
}

-(IBAction)nuevaVentana: (id)sender
{
	AppController* app = [[AppController alloc] init];
	[app showWindow: self];
}

@end
